<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <include file="./Public/Admin/header.html" />
    <style>
        .form-horizontal .control-group {
            margin-bottom: 10px;
        }

        .input-medium {
            width: 330px;
        }

        #keyword {
            width: 323px;
        }
        .span2{margin-bottom: 10px;}
        .span12{overflow: hidden;}
        .span12 .span5{float:left;width: 30%;}
        #discount input{width: 50px;height: 20px}
    </style>
</head>
<body>
<div id="main">
    <div class="container-fluid">

        <div class="row-fluid">
            <div class="span12">
                <div class="box">
                    <div class="box-title">
                        <div class="span4">
                            <h3><i class="icon-edit"></i>课程列表</h3>
                        </div>
                    </div>

                    <div class="box-content">

                        <div class="row-fluid">
                            <div class="span10 control-group">
                                <div class="span2" style="width: 100%;">
                                    <a class="btn" href="{:U('edit')}?action=add"><i class="icon-plus"></i>添加课程</a>
                                    <a class="btn" href="javascript:location.reload()"><i class="icon-refresh"></i>刷新</a>
                                </div>

                                <div><span>价格设置：</span>&nbsp<input type="text" name="discount" id="discount" value="{$discount.discount}">（折）<button type="button" id="sz_discount">确定</button></div>
                                <div class="btn-group pull-right clearfix " style="float: left;">
                                    <form action="{:U('index')}" method="get" class="form-horizontal" style="margin: 0px;">


                                                <div class="span4 ">
                                                    <input type="text" id="keyword" name="keyword" value="<?php echo $_GET['keyword'] ?>" class="input-small-z" placeholder="请输入课程名称" />
                                                    <button class="btn" id="btn_search">查询</button>
                                                </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="row-fluid dataTables_wrapper">
                            <table id="listTable" class="table table-bordered table-hover  dataTable">
                                <thead>
                                <tr>
                                    <th class='with-checkbox'>
                                        <input type="checkbox" class="check_all" /></th>

                                    <th>课程名称</th>
                                    <th>课程介绍</th>
                                    <th>图片地址</th>
                                    <th>现价/原价(元)</th>
                                    <th>开课时间</th>
                                    <th>结课时间</th>
                                    <th>课程分类</th>
                                    <th>期数</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <foreach name="list" item="v">
                                    <tr>
                                        <td class="with-checkbox">
                                            <input type="checkbox" name="check" value="{$v.id}">
                                        </td>
                                        <td ><?php echo $v['name']?></td>
                                        <td ><?php echo $v['value']?></td>
                                        <td ><?php echo $v['images']?></td>
                                        <td ><?php echo $v['money']*($discount['discount']/10)?>(<?php echo $v['money']?>)</td>
                                        <td ><?php echo $v['startime']?></td>
                                        <td ><?php echo $v['endtime']?></td>
                                        <td ><?php echo $v['type']?></td>
                                        <td ><?php echo $v['stages']?></td>
                                        <td>
                                            <a href="{:U('setClass')}?id={$v.id}" class="btn" rel="tooltip" title="设置"><i class="icon-edit">设置</i></a>
                                            <a href="{:U('edit')}?action=edit&id={$v.id}" class="btn" rel="tooltip" title="编辑"><i class="icon-edit">编辑</i></a>
                                            <a href="javascript:void(0);" class="btn" rel="tooltip" title="删除" attr="deltext_info_{$v.id}"><i class="icon-remove">删除</i></a>
                                           </td>
                                    </tr>

                                </foreach>
                                <if condition="($count eq 0) ">
                                    <tr><td align="center" colspan="11">暂无记录</td></tr>
                                </if>
                                </tbody>
                            </table>
                            <div class="row-fluid">
                                <div class="span4">
                                    <div class="dataTables_info">
                                        <if condition="($count gt 0) ">
                                            共{$count}条记录，当前第{$nowPage}/{$totalPages}页
                                        </if>
                                    </div>
                                </div>
                                <div class="span8">
                                    {$page}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">

    $('#sz_discount').click(function () {
       var dis = $('#discount').val();
        $.post("setDis",{data:dis},function(result){
            console.log(result);
            if (result == 1){
                alert('设置成功');
            }else {
                alert('设置失败');
            }
        });
    });

    $(function(){
        //删除内容
        $("a[attr^='deltext_info_']").click(function(){
            var tmp = $(this).attr('attr').split('_');
            var ids = new Array();
            ids[0]=tmp[2];
            delText(ids);
        });
        $("[attr='BatchDelInfo']").click(function(){
            var check = $("input:checked");
            if(check.length<1){
                G.ui.tips.err('请选择删除项');
                return false;
            }
            var ids = new Array();
            check.each(function(i){
                ids[i] = $(this).val();
            });
            delText(ids);
        });
    });
    //删除内容
    function delText(ids){
        G.ui.tips.confirm_flag('您确定要删除吗?',function(){
            $.post("{:U('del')}", {ids:ids},function(data){
                if (data.errno ==0)
                {
                    location.reload();
                } else {

                    G.ui.tips.err(data.error);
                }
            },'json');
        });
    }
</script>
</body>
</html>